extends ../public/layout
block title
    title 支付方式
block content
    .am-g.am-padding-lg.am-text-center.white-background
        span.am-text-center.payInfo 正在支付中.......
block javascript
    script(type="text/javascript").
        $(function () {
            (function ($) {
                $.getUrlParam = function (name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                }
            })(jQuery);
            var payParams = $.getUrlParam('params');
            if(!payParams){
                messageBox("获取参数失败");
                return;
            }
            var isReturn = false;
            setInterval(function () {
                if(isReturn){
                    $.getJSON('/check/return?params='+payParams).then(function (msg) {
                        isReturn = true;
                        if(msg.code == 200){
                            $('.payInfo').text('支付成功');
                            setTimeout(function () {
                                window.location.href = '/orders';
                            },2000);
                        }
                    })
                }
            },1000)
        });
